package com.inmobi.androidsdk;

import android.app.Activity;
import android.content.Context;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.os.Build.VERSION;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import com.inmobi.androidsdk.bootstrapper.ConfigParams;
import com.inmobi.androidsdk.bootstrapper.Initializer;
import com.inmobi.androidsdk.impl.ConfigException;
import com.inmobi.androidsdk.impl.ConnBroadcastReciever;
import com.inmobi.androidsdk.impl.SDKUtil;
import com.inmobi.androidsdk.impl.UserInfo;
import com.inmobi.androidsdk.impl.imai.IMAIController;
import com.inmobi.androidsdk.impl.metric.EventLog;
import com.inmobi.androidsdk.impl.metric.EventType;
import com.inmobi.androidsdk.impl.metric.Logger;
import com.inmobi.androidsdk.impl.net.HttpRequestCallback;
import com.inmobi.androidsdk.impl.net.RequestResponseManager;
import com.inmobi.commons.internal.InternalSDKUtil;
import com.inmobi.commons.internal.Log;
import com.inmobi.commons.internal.ThinICE;
import com.inmobi.commons.uid.UIDHelper;
import com.inmobi.re.container.IMWebView;
import com.inmobi.re.container.IMWebView.IMWebViewListener;
import com.inmobi.re.container.IMWebView.ViewState;
import com.inmobi.re.container.WrapperFunctions;
import com.inmobi.re.container.mraidimpl.MRAIDInterstitialController;
import java.lang.ref.WeakReference;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONException;
import org.json.JSONObject;

public final class IMAdView extends RelativeLayout
{
  public static final int INMOBI_AD_UNIT_120X600 = 13;
  public static final int INMOBI_AD_UNIT_300X250 = 10;
  public static final int INMOBI_AD_UNIT_320X48 = 9;
  public static final int INMOBI_AD_UNIT_320X50 = 15;
  public static final int INMOBI_AD_UNIT_468X60 = 12;
  public static final int INMOBI_AD_UNIT_728X90 = 11;
  public static final String INMOBI_INTERNAL_TAG = "ref-__in__rt";
  public static final String INMOBI_REF_TAG = "ref-tag";
  public static final int REFRESH_INTERVAL_OFF = -1;
  private boolean A;
  private a B = new a(this);
  private Animation.AnimationListener C = new a(this);
  private HttpRequestCallback D = new c(this);
  private IMWebView.IMWebViewListener E = new b(this);
  private boolean F = true;
  private int a;
  private IMWebView b;
  private IMWebView c;
  private IMWebView d;
  private Activity e;
  private boolean f = true;
  private UserInfo g;
  private AtomicBoolean h = new AtomicBoolean();
  private AtomicBoolean i = new AtomicBoolean();
  private Animation j;
  private Animation k;
  private String l = null;
  private String m = null;
  private IMAdListener n;
  private IMAdRequest o;
  private String p;
  private int q;
  private long r = -1L;
  private long s = 0L;
  private long t = 0L;
  private boolean u = true;
  private AnimationType v = AnimationType.ROTATE_HORIZONTAL_AXIS;
  private boolean w = true;
  private d x;
  private String y = "http://i.w.inmobi.com/showad.asm";
  private RequestResponseManager z;

  public IMAdView(Activity paramActivity, int paramInt, String paramString)
  {
    this(paramActivity);
    a(paramActivity, paramInt, paramString);
  }

  public IMAdView(Activity paramActivity, int paramInt, String paramString, long paramLong)
  {
    this(paramActivity);
    this.r = paramLong;
    a(paramActivity, paramInt, paramString);
  }

  private IMAdView(Context paramContext)
  {
    super(paramContext);
  }

  public IMAdView(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    if (paramAttributeSet == null)
      throw new IllegalArgumentException("Missing attributes in xml layout of IMAdview ");
    String str1 = paramAttributeSet.getAttributeValue(null, "appId");
    int i1 = paramAttributeSet.getAttributeIntValue(null, "adSize", -1);
    String str2 = paramAttributeSet.getAttributeValue(null, "slotId");
    if (str2 != null)
      this.r = Long.parseLong(str2);
    a((Activity)paramContext, i1, str1);
  }

  private void a(int paramInt)
  {
    if (paramInt < 0)
      throw new IllegalArgumentException("Invalid Ad Size. Please provide a valid Ad Size. If Ad Size is declared in the layout XML, please provide a valid 'adSize' attribute in the 'com.inmobi.androidsdk.IMAdView' tag of layout XML. For example, adSize=\"yourAdSize\"");
  }

  private void a(final int paramInt, final IMAdRequest.ErrorCode paramErrorCode)
  {
    if (!this.w)
      Log.debug("InMobiAndroidSDK_3.7.0", "IMAdView not sending callback because the view is not added to any window.");
    while (this.n == null)
      return;
    this.e.runOnUiThread(new b(paramInt, paramErrorCode));
  }

  private void a(Activity paramActivity, int paramInt, String paramString)
  {
    try
    {
      SDKUtil.validateAdConfiguration(paramActivity);
      InternalSDKUtil.getUserAgent(paramActivity.getApplicationContext());
      this.a = Initializer.getConfigParams(getContext()).getDefaultRefreshRate();
      a(paramInt);
      SDKUtil.validateAppID(paramString);
      this.p = paramString;
      this.q = paramInt;
      this.e = SDKUtil.getRootActivity(paramActivity);
      IMWebView.setIMAIController(IMAIController.class);
    }
    catch (ConfigException localConfigException)
    {
      try
      {
        String str = UIDHelper.getAndroidId(paramActivity.getApplicationContext());
        Log.debug("InMobiAndroidSDK_3.7.0", "Publisher device Id is " + UIDHelper.getODIN1(str));
        ThinICE.start(this.e);
        if (this.b == null)
        {
          this.b = new IMWebView(this.e, this.E, false, false);
          if (!this.F)
            this.b.disableHardwareAcceleration();
          this.b.addJavascriptInterface(new IMAIController(this.b), "imaiController");
        }
        if (this.c == null)
        {
          this.c = new IMWebView(this.e, this.E, false, false);
          if (!this.F)
            this.c.disableHardwareAcceleration();
          RelativeLayout.LayoutParams localLayoutParams = new RelativeLayout.LayoutParams(-1, -1);
          this.d = this.c;
          addView(this.c, localLayoutParams);
          this.c.addJavascriptInterface(new IMAIController(this.c), "imaiController");
        }
        d();
        this.x = new d(this, this.C);
        this.e.getApplicationContext().registerReceiver(new ConnBroadcastReciever(), new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
        return;
        localConfigException = localConfigException;
        Log.internal("InMobiAndroidSDK_3.7.0", "IMConfigException occured while initializing interstitial while validating adView", localConfigException);
      }
      catch (Exception localException)
      {
        while (true)
          Log.internal("InMobiAndroidSDK_3.7.0", "Cannot get publisher device id", localException);
      }
    }
  }

  private void a(String paramString)
  {
    if (paramString != null)
    {
      if (Build.VERSION.SDK_INT <= 8)
        paramString.replaceAll("%", "%25");
      if (i())
        if (this.b == null)
        {
          this.b = new IMWebView(this.e, this.E, false, false);
          if (!this.F)
            this.b.disableHardwareAcceleration();
        }
      for (IMWebView localIMWebView = this.b; ; localIMWebView = this.c)
      {
        localIMWebView.addJavascriptInterface(new IMAIController(localIMWebView), "imaiController");
        localIMWebView.requestOnPageFinishedCallback(this.B.obtainMessage(101));
        this.s = System.currentTimeMillis();
        this.B.sendEmptyMessageDelayed(108, Initializer.getConfigParams(getContext()).getRenderTimeOut());
        localIMWebView.resetMraid();
        localIMWebView.loadDataWithBaseURL("", paramString, "text/html", null, null);
        return;
        if (this.c == null)
        {
          this.c = new IMWebView(this.e, this.E, false, false);
          if (!this.F)
            this.c.disableHardwareAcceleration();
        }
      }
    }
    a(false);
    Log.debug("InMobiAndroidSDK_3.7.0", "Cannot load Ad. Invalid Ad Response");
    a(101, IMAdRequest.ErrorCode.INTERNAL_ERROR);
  }

  private void a(boolean paramBoolean)
  {
    this.h.set(paramBoolean);
  }

  private void b(boolean paramBoolean)
  {
    this.i.set(paramBoolean);
  }

  private void c()
  {
    int i1 = 320;
    float f1 = this.e.getResources().getDisplayMetrics().density;
    while (true)
    {
      try
      {
        switch (this.q)
        {
        case 9:
          if ((i1 != 0) && (i2 != 0))
          {
            int i3 = (int)(f1 * i1);
            int i4 = (int)(f1 * i2);
            getLayoutParams().height = i4;
            getLayoutParams().width = i3;
            setLayoutParams(getLayoutParams());
          }
          return;
          i2 = 48;
          break;
        case 10:
          i1 = 300;
          i2 = 250;
          break;
        case 11:
          i1 = 729;
          i2 = 90;
          break;
        case 12:
          i1 = 468;
          i2 = 60;
          break;
        case 13:
          i1 = 120;
          i2 = 600;
          break;
        case 15:
          i2 = 50;
          continue;
        case 14:
        }
      }
      catch (Exception localException)
      {
        Log.internal("InMobiAndroidSDK_3.7.0", "Cannot set default size for adview", localException);
        return;
      }
      int i2 = 0;
      i1 = 0;
    }
  }

  private void c(boolean paramBoolean)
  {
    this.f = paramBoolean;
    if (paramBoolean)
    {
      this.b.deinit();
      this.b = null;
      return;
    }
    this.c.deinit();
    this.c = null;
  }

  private void d()
  {
    if (this.g == null)
    {
      this.g = new UserInfo(this.e);
      DisplayMetrics localDisplayMetrics = new DisplayMetrics();
      this.e.getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
      float f1 = localDisplayMetrics.density;
      Display localDisplay = ((WindowManager)this.e.getSystemService("window")).getDefaultDisplay();
      int i1 = (int)(WrapperFunctions.getDisplayWidth(localDisplay) / f1);
      int i2 = (int)(WrapperFunctions.getDisplayHeight(localDisplay) / f1);
      this.g.setScreenDensity(String.valueOf(f1));
      this.g.setScreenSize("" + i1 + "X" + i2);
    }
    try
    {
      if ((this.b != null) && (this.g.getPhoneDefaultUserAgent().equals("")))
        this.g.setPhoneDefaultUserAgent(InternalSDKUtil.getUserAgent(this.e.getApplicationContext()));
      this.g.setAdUnitSlot(String.valueOf(this.q));
      if (this.r != -1L)
        this.g.setSlotId(Long.toString(this.r));
      this.g.updateInfo(this.p, this.o);
      return;
    }
    catch (Exception localException)
    {
      while (true)
        Log.debug("InMobiAndroidSDK_3.7.0", "Exception occured while setting user agent" + localException);
    }
  }

  private void e()
  {
    try
    {
      removeAllViews();
      if (i())
      {
        RelativeLayout.LayoutParams localLayoutParams1 = new RelativeLayout.LayoutParams(-1, -1);
        this.d = this.b;
        addView(this.b, localLayoutParams1);
      }
      while (true)
      {
        boolean bool1 = i();
        boolean bool2 = false;
        if (!bool1)
          bool2 = true;
        c(bool2);
        a(false);
        j();
        return;
        RelativeLayout.LayoutParams localLayoutParams2 = new RelativeLayout.LayoutParams(-1, -1);
        this.d = this.c;
        addView(this.c, localLayoutParams2);
      }
    }
    catch (Exception localException)
    {
      Log.debug("InMobiAndroidSDK_3.7.0", "Error swapping banner ads", localException);
      return;
    }
    finally
    {
      a(100, null);
    }
  }

  private boolean f()
  {
    if ((!SDKUtil.getQAMode()) && (!InternalSDKUtil.validateAppId(this.p)))
      return false;
    if (this.q < 0)
    {
      Log.debug("InMobiAndroidSDK_3.7.0", "Invalid Ad Size. Please provide a valid adSize.");
      return false;
    }
    return true;
  }

  private boolean g()
  {
    return this.h.get();
  }

  private boolean h()
  {
    if (this.i.get())
      return true;
    if (i());
    for (IMWebView localIMWebView = this.c; ; localIMWebView = this.b)
    {
      String str = localIMWebView.getState();
      Log.debug("InMobiAndroidSDK_3.7.0", "Current Ad State: " + str);
      if ((!IMWebView.ViewState.EXPANDED.toString().equalsIgnoreCase(str)) && (!IMWebView.ViewState.RESIZED.toString().equalsIgnoreCase(str)) && (!IMWebView.ViewState.RESIZING.toString().equalsIgnoreCase(str)) && (!IMWebView.ViewState.EXPANDING.toString().equalsIgnoreCase(str)))
        break;
      Log.debug("InMobiAndroidSDK_3.7.0", "Current Ad State is neither default nor loading. New ad will not be shown.");
      return true;
    }
    if (localIMWebView.isBusy())
    {
      Log.debug("InMobiAndroidSDK_3.7.0", "New ad will not be shown because the present ad is busy. Eg. Video/audio is playing, etc.");
      return true;
    }
    return false;
  }

  private boolean i()
  {
    return this.f;
  }

  private void j()
  {
    try
    {
      if (this.c != null)
        this.c.setBackgroundColor(0);
      if (this.b != null)
        this.b.setBackgroundColor(0);
      return;
    }
    catch (Exception localException)
    {
      Log.debug("InMobiAndroidSDK_3.7.0", "Error setNormalBGColor", localException);
    }
  }

  private void k()
  {
    this.B.removeMessages(100);
    int i1 = Initializer.getConfigParams(getContext()).getMinimumRefreshRate();
    if (this.a < i1)
    {
      this.B.sendEmptyMessageDelayed(100, i1 * 1000);
      return;
    }
    this.B.sendEmptyMessageDelayed(100, 1000 * this.a);
  }

  private void l()
  {
    if (this.B.hasMessages(100))
      this.B.removeMessages(100);
    this.B.sendEmptyMessageDelayed(100, 1000 * this.a);
  }

  private void setAdServerUrl(String paramString)
  {
    this.y = paramString;
  }

  Animation a()
  {
    return this.j;
  }

  void a(Animation paramAnimation)
  {
    this.j = paramAnimation;
  }

  Animation b()
  {
    return this.k;
  }

  void b(Animation paramAnimation)
  {
    this.k = paramAnimation;
  }

  public void destroy()
  {
    try
    {
      if (this.d != null)
        this.d.destroy();
      this.d = null;
      return;
    }
    catch (Exception localException)
    {
      while (true)
        Log.debug("InMobiAndroidSDK_3.7.0", "Unable to destroy webview, or it has been destroyed already.");
    }
  }

  public void disableHardwareAcceleration()
  {
    this.F = false;
    if (this.d != null)
      this.d.disableHardwareAcceleration();
  }

  public int getAdSize()
  {
    return this.q;
  }

  public RelativeLayout.LayoutParams getAdViewPosition()
  {
    int[] arrayOfInt = new int[2];
    RelativeLayout.LayoutParams localLayoutParams1;
    if ((this.d == null) || (this.d.getLayoutParams() == null) || (this.d.getParent() == this))
    {
      localLayoutParams1 = new RelativeLayout.LayoutParams(getLayoutParams());
      localLayoutParams1.width = getWidth();
      localLayoutParams1.height = getHeight();
      getLocationOnScreen(arrayOfInt);
      localLayoutParams1.leftMargin = arrayOfInt[0];
      localLayoutParams1.topMargin = arrayOfInt[1];
    }
    RelativeLayout.LayoutParams localLayoutParams2;
    for (Object localObject = localLayoutParams1; ; localObject = localLayoutParams2)
    {
      ((FrameLayout)getRootView().findViewById(16908290)).getLocationOnScreen(arrayOfInt);
      ((RelativeLayout.LayoutParams)localObject).leftMargin -= arrayOfInt[0];
      ((RelativeLayout.LayoutParams)localObject).topMargin -= arrayOfInt[1];
      ((RelativeLayout.LayoutParams)localObject).rightMargin = 0;
      ((RelativeLayout.LayoutParams)localObject).bottomMargin = 0;
      return localObject;
      localLayoutParams2 = new RelativeLayout.LayoutParams(this.d.getLayoutParams());
      localLayoutParams2.width = this.d.getWidth();
      localLayoutParams2.height = this.d.getHeight();
      this.d.getLocationOnScreen(arrayOfInt);
      localLayoutParams2.leftMargin = arrayOfInt[0];
      localLayoutParams2.topMargin = arrayOfInt[1];
    }
  }

  public String getAppId()
  {
    return this.p;
  }

  public IMAdListener getIMAdListener()
  {
    return this.n;
  }

  public IMAdRequest getIMAdRequest()
  {
    return this.o;
  }

  public long getSlotId()
  {
    return this.r;
  }

  public boolean isModal()
  {
    if (this.d != null)
      return this.d.isModal();
    return false;
  }

  // ERROR //
  public void loadNewAd()
  {
    // Byte code:
    //   0: aload_0
    //   1: monitorenter
    //   2: aload_0
    //   3: new 712	com/inmobi/androidsdk/impl/net/RequestResponseManager
    //   6: dup
    //   7: invokespecial 713	com/inmobi/androidsdk/impl/net/RequestResponseManager:<init>	()V
    //   10: putfield 619	com/inmobi/androidsdk/IMAdView:z	Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;
    //   13: aload_0
    //   14: aload_0
    //   15: invokevirtual 232	com/inmobi/androidsdk/IMAdView:getContext	()Landroid/content/Context;
    //   18: invokestatic 719	com/inmobi/androidsdk/impl/metric/Logger:startNewSample	(Landroid/content/Context;)Z
    //   21: putfield 468	com/inmobi/androidsdk/IMAdView:A	Z
    //   24: aload_0
    //   25: getfield 201	com/inmobi/androidsdk/IMAdView:e	Landroid/app/Activity;
    //   28: invokevirtual 223	android/app/Activity:getApplicationContext	()Landroid/content/Context;
    //   31: invokestatic 272	com/inmobi/commons/uid/UIDHelper:getAndroidId	(Landroid/content/Context;)Ljava/lang/String;
    //   34: astore 5
    //   36: ldc 191
    //   38: new 274	java/lang/StringBuilder
    //   41: dup
    //   42: invokespecial 275	java/lang/StringBuilder:<init>	()V
    //   45: ldc_w 277
    //   48: invokevirtual 281	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   51: aload 5
    //   53: invokestatic 285	com/inmobi/commons/uid/UIDHelper:getODIN1	(Ljava/lang/String;)Ljava/lang/String;
    //   56: invokevirtual 281	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   59: invokevirtual 289	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   62: invokestatic 199	com/inmobi/commons/internal/Log:debug	(Ljava/lang/String;Ljava/lang/String;)V
    //   65: ldc 191
    //   67: ldc_w 721
    //   70: invokestatic 199	com/inmobi/commons/internal/Log:debug	(Ljava/lang/String;Ljava/lang/String;)V
    //   73: aload_0
    //   74: getfield 201	com/inmobi/androidsdk/IMAdView:e	Landroid/app/Activity;
    //   77: invokevirtual 223	android/app/Activity:getApplicationContext	()Landroid/content/Context;
    //   80: invokestatic 724	com/inmobi/commons/internal/InternalSDKUtil:checkNetworkAvailibility	(Landroid/content/Context;)Z
    //   83: ifne +33 -> 116
    //   86: aload_0
    //   87: bipush 101
    //   89: getstatic 727	com/inmobi/androidsdk/IMAdRequest$ErrorCode:NETWORK_ERROR	Lcom/inmobi/androidsdk/IMAdRequest$ErrorCode;
    //   92: invokespecial 356	com/inmobi/androidsdk/IMAdView:a	(ILcom/inmobi/androidsdk/IMAdRequest$ErrorCode;)V
    //   95: aload_0
    //   96: monitorexit
    //   97: return
    //   98: astore_2
    //   99: ldc 191
    //   101: ldc_w 354
    //   104: aload_2
    //   105: invokestatic 352	com/inmobi/commons/internal/Log:internal	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   108: goto -43 -> 65
    //   111: astore_1
    //   112: aload_0
    //   113: monitorexit
    //   114: aload_1
    //   115: athrow
    //   116: aload_0
    //   117: invokespecial 729	com/inmobi/androidsdk/IMAdView:g	()Z
    //   120: ifeq +28 -> 148
    //   123: aload_0
    //   124: bipush 101
    //   126: getstatic 732	com/inmobi/androidsdk/IMAdRequest$ErrorCode:AD_DOWNLOAD_IN_PROGRESS	Lcom/inmobi/androidsdk/IMAdRequest$ErrorCode;
    //   129: invokespecial 356	com/inmobi/androidsdk/IMAdView:a	(ILcom/inmobi/androidsdk/IMAdRequest$ErrorCode;)V
    //   132: goto -37 -> 95
    //   135: astore_3
    //   136: ldc 191
    //   138: ldc_w 734
    //   141: aload_3
    //   142: invokestatic 567	com/inmobi/commons/internal/Log:debug	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   145: goto -50 -> 95
    //   148: aload_0
    //   149: invokespecial 736	com/inmobi/androidsdk/IMAdView:h	()Z
    //   152: ifeq +15 -> 167
    //   155: aload_0
    //   156: bipush 101
    //   158: getstatic 739	com/inmobi/androidsdk/IMAdRequest$ErrorCode:AD_CLICK_IN_PROGRESS	Lcom/inmobi/androidsdk/IMAdRequest$ErrorCode;
    //   161: invokespecial 356	com/inmobi/androidsdk/IMAdView:a	(ILcom/inmobi/androidsdk/IMAdRequest$ErrorCode;)V
    //   164: goto -69 -> 95
    //   167: aload_0
    //   168: invokespecial 741	com/inmobi/androidsdk/IMAdView:f	()Z
    //   171: ifne +15 -> 186
    //   174: aload_0
    //   175: bipush 101
    //   177: getstatic 744	com/inmobi/androidsdk/IMAdRequest$ErrorCode:INVALID_REQUEST	Lcom/inmobi/androidsdk/IMAdRequest$ErrorCode;
    //   180: invokespecial 356	com/inmobi/androidsdk/IMAdView:a	(ILcom/inmobi/androidsdk/IMAdRequest$ErrorCode;)V
    //   183: goto -88 -> 95
    //   186: aload_0
    //   187: iconst_1
    //   188: invokespecial 363	com/inmobi/androidsdk/IMAdView:a	(Z)V
    //   191: aload_0
    //   192: invokespecial 325	com/inmobi/androidsdk/IMAdView:d	()V
    //   195: aload_0
    //   196: getfield 471	com/inmobi/androidsdk/IMAdView:g	Lcom/inmobi/androidsdk/impl/UserInfo;
    //   199: ifnull +11 -> 210
    //   202: aload_0
    //   203: getfield 471	com/inmobi/androidsdk/IMAdView:g	Lcom/inmobi/androidsdk/impl/UserInfo;
    //   206: iconst_0
    //   207: invokevirtual 747	com/inmobi/androidsdk/impl/UserInfo:setRefreshType	(I)V
    //   210: aload_0
    //   211: invokestatic 394	java/lang/System:currentTimeMillis	()J
    //   214: putfield 106	com/inmobi/androidsdk/IMAdView:t	J
    //   217: aload_0
    //   218: getfield 128	com/inmobi/androidsdk/IMAdView:B	Lcom/inmobi/androidsdk/IMAdView$a;
    //   221: bipush 107
    //   223: aload_0
    //   224: invokevirtual 232	com/inmobi/androidsdk/IMAdView:getContext	()Landroid/content/Context;
    //   227: invokestatic 238	com/inmobi/androidsdk/bootstrapper/Initializer:getConfigParams	(Landroid/content/Context;)Lcom/inmobi/androidsdk/bootstrapper/ConfigParams;
    //   230: invokevirtual 750	com/inmobi/androidsdk/bootstrapper/ConfigParams:getFetchTimeOut	()I
    //   233: i2l
    //   234: invokevirtual 401	com/inmobi/androidsdk/IMAdView$a:sendEmptyMessageDelayed	(IJ)Z
    //   237: pop
    //   238: aload_0
    //   239: getfield 128	com/inmobi/androidsdk/IMAdView:B	Lcom/inmobi/androidsdk/IMAdView$a;
    //   242: bipush 100
    //   244: invokevirtual 622	com/inmobi/androidsdk/IMAdView$a:removeMessages	(I)V
    //   247: aload_0
    //   248: getfield 619	com/inmobi/androidsdk/IMAdView:z	Lcom/inmobi/androidsdk/impl/net/RequestResponseManager;
    //   251: aload_0
    //   252: getfield 471	com/inmobi/androidsdk/IMAdView:g	Lcom/inmobi/androidsdk/impl/UserInfo;
    //   255: getstatic 756	com/inmobi/androidsdk/impl/net/RequestResponseManager$ActionType:AdRequest	Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$ActionType;
    //   258: aload_0
    //   259: getfield 121	com/inmobi/androidsdk/IMAdView:y	Ljava/lang/String;
    //   262: aload_0
    //   263: getfield 138	com/inmobi/androidsdk/IMAdView:D	Lcom/inmobi/androidsdk/impl/net/HttpRequestCallback;
    //   266: invokevirtual 760	com/inmobi/androidsdk/impl/net/RequestResponseManager:asyncRequestAd	(Lcom/inmobi/androidsdk/impl/UserInfo;Lcom/inmobi/androidsdk/impl/net/RequestResponseManager$ActionType;Ljava/lang/String;Lcom/inmobi/androidsdk/impl/net/HttpRequestCallback;)V
    //   269: goto -174 -> 95
    //
    // Exception table:
    //   from	to	target	type
    //   24	65	98	java/lang/Exception
    //   2	24	111	finally
    //   24	65	111	finally
    //   65	73	111	finally
    //   73	95	111	finally
    //   99	108	111	finally
    //   116	132	111	finally
    //   136	145	111	finally
    //   148	164	111	finally
    //   167	183	111	finally
    //   186	210	111	finally
    //   210	269	111	finally
    //   73	95	135	java/lang/Exception
    //   116	132	135	java/lang/Exception
    //   148	164	135	java/lang/Exception
    //   167	183	135	java/lang/Exception
    //   186	210	135	java/lang/Exception
    //   210	269	135	java/lang/Exception
  }

  public void loadNewAd(IMAdRequest paramIMAdRequest)
  {
    if (paramIMAdRequest != null)
      setIMAdRequest(paramIMAdRequest);
    loadNewAd();
  }

  protected void onAttachedToWindow()
  {
    Log.debug("InMobiAndroidSDK_3.7.0", "onAttachedToWindow");
    this.w = true;
    c();
    setRefreshInterval(this.a);
  }

  protected void onDetachedFromWindow()
  {
    Log.debug("InMobiAndroidSDK_3.7.0", "onDetatchedFromWindow");
    this.w = false;
    setRefreshInterval(-1);
    if (i());
    for (IMWebView localIMWebView = this.c; ; localIMWebView = this.b)
    {
      if (localIMWebView != null)
        localIMWebView.deinit();
      return;
    }
  }

  protected void onWindowVisibilityChanged(int paramInt)
  {
    super.onWindowVisibilityChanged(paramInt);
    if (paramInt == 0)
    {
      l();
      ThinICE.start(this.e);
      RequestResponseManager localRequestResponseManager = new RequestResponseManager();
      localRequestResponseManager.init();
      localRequestResponseManager.processClickInBackground(this.e.getApplicationContext());
    }
  }

  @Deprecated
  public void setAdBackgroundColor(String paramString)
  {
  }

  @Deprecated
  public void setAdBackgroundGradientColor(String paramString1, String paramString2)
  {
  }

  public void setAdSize(int paramInt)
  {
    a(paramInt);
    this.q = paramInt;
  }

  @Deprecated
  public void setAdTextColor(String paramString)
  {
  }

  public void setAnimationType(AnimationType paramAnimationType)
  {
    this.v = paramAnimationType;
  }

  public void setAppId(String paramString)
  {
    SDKUtil.validateAppID(paramString);
    this.p = paramString;
  }

  public void setIMAdListener(IMAdListener paramIMAdListener)
  {
    this.n = paramIMAdListener;
  }

  public void setIMAdRequest(IMAdRequest paramIMAdRequest)
  {
    this.o = paramIMAdRequest;
  }

  public void setRefTagParam(String paramString1, String paramString2)
  {
    if ((paramString1 == null) || (paramString2 == null))
      throw new NullPointerException("Key or Value cannot be null");
    if ((paramString1.trim().equals("")) || (paramString2.trim().equals("")))
      throw new IllegalArgumentException("Key or Value cannot be empty");
    if (this.g != null)
    {
      this.g.setRefTagKey(paramString1.toLowerCase(Locale.ENGLISH));
      this.g.setRefTagValue(paramString2.toLowerCase(Locale.ENGLISH));
    }
  }

  public void setRefreshInterval(int paramInt)
  {
    if (paramInt == -1)
    {
      this.a = -1;
      this.B.removeMessages(100);
      return;
    }
    int i1 = Initializer.getConfigParams(getContext()).getMinimumRefreshRate();
    if (paramInt < i1)
    {
      Log.debug("InMobiAndroidSDK_3.7.0", "Refresh Interval cannot be less than " + i1 + " seconds. Setting refresh rate to " + i1);
      this.a = 0;
    }
    this.a = paramInt;
    k();
  }

  public void setSlotId(long paramLong)
  {
    this.r = paramLong;
  }

  public void stopLoading()
  {
    if (this.B.hasMessages(107))
    {
      this.B.removeMessages(107);
      this.B.sendEmptyMessage(107);
    }
    while (!this.B.hasMessages(108))
      return;
    this.B.removeMessages(108);
    this.B.sendEmptyMessage(108);
  }

  public static enum AnimationType
  {
    static
    {
      ANIMATION_ALPHA = new AnimationType("ANIMATION_ALPHA", 2);
      ROTATE_VERTICAL_AXIS = new AnimationType("ROTATE_VERTICAL_AXIS", 3);
      AnimationType[] arrayOfAnimationType = new AnimationType[4];
      arrayOfAnimationType[0] = ANIMATION_OFF;
      arrayOfAnimationType[1] = ROTATE_HORIZONTAL_AXIS;
      arrayOfAnimationType[2] = ANIMATION_ALPHA;
      arrayOfAnimationType[3] = ROTATE_VERTICAL_AXIS;
    }
  }

  static class a extends Handler
  {
    private final WeakReference<IMAdView> a;

    public a(IMAdView paramIMAdView)
    {
      this.a = new WeakReference(paramIMAdView);
    }

    public void handleMessage(Message paramMessage)
    {
      IMAdView localIMAdView = (IMAdView)this.a.get();
      if (localIMAdView != null)
        switch (paramMessage.what)
        {
        case 103:
        default:
        case 109:
        case 110:
        case 111:
        case 108:
        case 107:
        case 100:
        case 101:
        case 102:
        case 104:
        case 105:
        case 106:
        }
      while (true)
      {
        super.handleMessage(paramMessage);
        do
          while (true)
          {
            while (true)
            {
              while (true)
              {
                return;
                long l4;
                JSONObject localJSONObject4;
                if (IMAdView.c(localIMAdView))
                {
                  l4 = System.currentTimeMillis() - IMAdView.d(localIMAdView);
                  localJSONObject4 = new JSONObject();
                }
                try
                {
                  localJSONObject4.put("ad", IMAdView.e(localIMAdView));
                  localJSONObject4.put("t", l4);
                  Logger.logEvent(localIMAdView.getContext().getApplicationContext(), new EventLog(EventType.FETCH_COMPLETE, localJSONObject4));
                  removeMessages(107);
                  IMAdView.a(localIMAdView, IMAdView.f(localIMAdView));
                }
                catch (JSONException localJSONException4)
                {
                  while (true)
                    Log.internal("InMobiAndroidSDK_3.7.0", "Error creating metric logs for fetch_complete at " + System.currentTimeMillis());
                }
              }
              removeMessages(107);
              IMAdView.a(localIMAdView, 101, (IMAdRequest.ErrorCode)paramMessage.obj);
              IMAdView.a(localIMAdView, false);
              break;
              removeMessages(108);
              removeMessages(101);
              IMAdView.a(localIMAdView, 101, IMAdRequest.ErrorCode.INTERNAL_ERROR);
              break;
              long l3;
              JSONObject localJSONObject3;
              if (IMAdView.c(localIMAdView))
              {
                l3 = System.currentTimeMillis() - IMAdView.g(localIMAdView);
                localJSONObject3 = new JSONObject();
              }
              try
              {
                localJSONObject3.put("ad", IMAdView.e(localIMAdView));
                localJSONObject3.put("t", l3);
                Logger.logEvent(localIMAdView.getContext().getApplicationContext(), new EventLog(EventType.RENDER_TIMEOUT, localJSONObject3));
                removeMessages(111);
                removeMessages(101);
                IMAdView.a(localIMAdView, false);
                if (IMAdView.h(localIMAdView))
                {
                  localIMWebView = IMAdView.i(localIMAdView);
                  IMAdView.a(localIMAdView, null);
                  localIMWebView.cancelLoad();
                  localIMWebView.stopLoading();
                  localIMWebView.deinit();
                  IMAdView.a(localIMAdView, 101, IMAdRequest.ErrorCode.AD_RENDERING_TIMEOUT);
                }
              }
              catch (JSONException localJSONException3)
              {
                while (true)
                {
                  Log.internal("InMobiAndroidSDK_3.7.0", "Error creating metric logs for fetch_complete at " + System.currentTimeMillis());
                  continue;
                  IMWebView localIMWebView = IMAdView.j(localIMAdView);
                  IMAdView.b(localIMAdView, null);
                }
              }
            }
            removeMessages(109);
            removeMessages(110);
            IMAdView.k(localIMAdView).doCancel();
            long l2 = System.currentTimeMillis() - IMAdView.d(localIMAdView);
            JSONObject localJSONObject2;
            if (IMAdView.c(localIMAdView))
              localJSONObject2 = new JSONObject();
            try
            {
              localJSONObject2.put("t", l2);
              localJSONObject2.put("m", 1);
              Logger.logEvent(localIMAdView.getContext().getApplicationContext(), new EventLog(EventType.CONNECT_ERROR, localJSONObject2));
              IMAdView.a(localIMAdView, false);
              IMAdView.a(localIMAdView, 101, IMAdRequest.ErrorCode.AD_FETCH_TIMEOUT);
            }
            catch (JSONException localJSONException2)
            {
              while (true)
                Log.internal("InMobiAndroidSDK_3.7.0", "Error creating metric logs for error at " + System.currentTimeMillis());
            }
          }
        while (IMAdView.l(localIMAdView) == -1);
        if (!IMAdView.m(localIMAdView).hasWindowFocus())
          Log.debug("InMobiAndroidSDK_3.7.0", "Activity is not in the foreground. New ad will not be loaded.");
        while (IMAdView.n(localIMAdView) != null)
        {
          IMAdView.n(localIMAdView).setRefreshType(1);
          break;
          if (MRAIDInterstitialController.isInterstitialDisplayed.get())
            Log.debug("InMobiAndroidSDK_3.7.0", "Ad cannot be loaded.Interstitial Ad is displayed.");
          else
            localIMAdView.loadNewAd();
        }
        long l1;
        JSONObject localJSONObject1;
        if (IMAdView.c(localIMAdView))
        {
          l1 = System.currentTimeMillis() - IMAdView.d(localIMAdView);
          localJSONObject1 = new JSONObject();
        }
        try
        {
          localJSONObject1.put("ad", IMAdView.e(localIMAdView));
          localJSONObject1.put("t", l1);
          Logger.logEvent(localIMAdView.getContext().getApplicationContext(), new EventLog(EventType.RENDER_COMPLETE, localJSONObject1));
          removeMessages(108);
          if (IMAdView.o(localIMAdView))
          {
            IMAdView.p(localIMAdView);
            IMAdView.b(localIMAdView, false);
          }
        }
        catch (JSONException localJSONException1)
        {
          while (true)
            Log.internal("InMobiAndroidSDK_3.7.0", "Error creating metric logs for fetch_complete at " + System.currentTimeMillis());
          if (IMAdView.q(localIMAdView) == IMAdView.AnimationType.ANIMATION_OFF)
          {
            IMAdView.p(localIMAdView);
            continue;
          }
          IMAdView.r(localIMAdView).a(IMAdView.q(localIMAdView));
        }
        continue;
        IMAdView.c(localIMAdView, false);
        continue;
        IMAdView.a(localIMAdView, 103, null);
        continue;
        IMAdView.a(localIMAdView, 102, null);
        continue;
        IMAdView.a(localIMAdView, 104, null);
      }
    }
  }

  class b
    implements Runnable
  {
    b(int paramErrorCode, IMAdRequest.ErrorCode arg3)
    {
    }

    public void run()
    {
      try
      {
        switch (paramInt)
        {
        default:
          Log.debug("InMobiAndroidSDK_3.7.0", paramErrorCode.toString());
          return;
        case 100:
          IMAdView.a(IMAdView.this).onAdRequestCompleted(IMAdView.this);
          IMAdView.b(IMAdView.this);
          return;
        case 101:
        case 103:
        case 102:
        case 104:
        case 105:
        case 106:
        }
      }
      catch (Exception localException)
      {
        Log.debug("InMobiAndroidSDK_3.7.0", "Exception giving callback to the publisher ", localException);
        return;
      }
      IMAdView.b(IMAdView.this);
      switch (IMAdView.c.a[paramErrorCode.ordinal()])
      {
      default:
        Log.debug("InMobiAndroidSDK_3.7.0", paramErrorCode.toString());
      case 1:
      case 2:
      case 3:
      case 4:
      }
      while (true)
      {
        IMAdView.a(IMAdView.this).onAdRequestFailed(IMAdView.this, paramErrorCode);
        return;
        Log.debug("InMobiAndroidSDK_3.7.0", "Ad click in progress. Your request cannot be processed at this time. Try again later.");
        continue;
        Log.debug("InMobiAndroidSDK_3.7.0", "Ad download in progress. Your request cannot be processed at this time. Try again later.");
        continue;
        Log.debug("InMobiAndroidSDK_3.7.0", "Ad request successful, but no ad was returned due to lack of ad inventory.");
        continue;
        Log.debug("InMobiAndroidSDK_3.7.0", "Your App Id may be invalid or inactive. Please verify the app ID");
      }
      IMAdView.a(IMAdView.this).onDismissAdScreen(IMAdView.this);
      return;
      IMAdView.a(IMAdView.this).onShowAdScreen(IMAdView.this);
      return;
      IMAdView.a(IMAdView.this).onLeaveApplication(IMAdView.this);
      return;
      IMAdView.a(IMAdView.this).onShowAdScreen(IMAdView.this);
      return;
      IMAdView.a(IMAdView.this).onDismissAdScreen(IMAdView.this);
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.inmobi.androidsdk.IMAdView
 * JD-Core Version:    0.6.2
 */